// Package service @program: gateway
//@author: edte
//@create: 2021-12-29 18:17
package service

import (
	"gateway/client/rank"
	"github.com/gin-gonic/gin"
	"log"
	"net/http"
)

type rankList struct {
	Token     string
	BoardName string
	StartPage int
	EndPage   int
}

func GetRankingList(ct *gin.Context) {
	json := rankList{}
	err := ct.BindJSON(&json)
	if err != nil || json.Token == "" {
		ct.JSON(http.StatusBadRequest, gin.H{"status": http.StatusBadRequest, "message": "请求格式不对"})
		return
	}
	board, err := rank.GetRankingBoard(json.Token, json.BoardName, json.StartPage, json.EndPage)
	if err != nil {
		log.Println(err)
		ct.JSON(http.StatusBadRequest, board)
		return
	}
	ct.JSON(http.StatusOK, board)
}
